const app = new getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    prompt: '',
    default_img: {},
    qrcode: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let order_id = app.checkEmpty(options.order_id, 0);
    if (! order_id > 0) {
      wx.navigateBack({
        delta: 1
      })
      return false;
    }
    this.setData({
      order_id: order_id
    });
    this.loadPickupQrcode();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  loadPickupQrcode: function () {
    let that = this;
    let order_id = that.data.order_id;

    app.sendRequest({
      url: 'System.Order.getAppletPickupQecode',
      data: {
        order_id: order_id
      },
      success: function (res) {
        if (res.code >= 0) {
          let info = app.checkEmpty(res.data, '');

          let qrcode = app.checkEmpty(info.path, '');
          if (qrcode != '') {
            qrcode = app.IMG(qrcode);
          }
          
          that.setData({
            qrcode: qrcode
          })
        }
      }
    })
  },
})